PTHMINT-96: Webhook validation for payloads with Unicode characters#42
Merged
danielcivit merged 1 commit intomasterfrom Jan 12, 2026
Merged
PTHMINT-96: Webhook validation for payloads with Unicode characters#42danielcivit merged 1 commit intomasterfrom
danielcivit merged 1 commit intomasterfrom
Conversation
- Update Webhook.validate to use ensure_ascii=False during JSON reconstruction. - Add unit test for Unicode support in webhook validation (e.g., 'ñ', '€'). (Fix)
There was a problem hiding this comment.
Pull request overview
This PR fixes webhook validation to correctly handle Unicode characters in payloads by ensuring the HMAC signature calculation preserves non-ASCII characters instead of escaping them.
Key changes:
- Modified JSON serialization in webhook validation to preserve Unicode characters
- Added comprehensive test coverage for Unicode character handling in webhook payloads
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/multisafepay/util/webhook.py | Added ensure_ascii=False parameter to json.dumps to preserve Unicode characters during signature validation |
| tests/multisafepay/unit/util/test_unit_webhook.py | Added new test case with Unicode characters and imported necessary cryptographic modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #42 +/- ##
=======================================
Coverage 90.69% 90.69%
=======================================
Files 143 143
Lines 2471 2471
=======================================
Hits 2241 2241
Misses 230 230 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
danielcivit
approved these changes
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the handling of unicode characters in webhook validation and enhances the test coverage to ensure correct behavior with non-ASCII payloads. The main changes are grouped into improvements in unicode support and expanded test coverage.
Unicode handling improvements:
json.dumpscall insrc/multisafepay/util/webhook.pyto useensure_ascii=False, allowing unicode characters to be preserved in the compact JSON used for HMAC signature calculation.Test coverage enhancements:
test_validate_with_unicode_characters, to verify that webhook validation works correctly when the payload contains unicode characters. This test ensures the signature is generated and validated as expected with non-ASCII data.base64,hashlib,hmac,time) intests/multisafepay/unit/util/test_unit_webhook.pyto support the new unicode validation test.- Update Webhook.validate to use ensure_ascii=False during JSON reconstruction.